<?php
require_once $_SERVER['DOCUMENT_ROOT'].'/entities/Person.php';
require_once $_SERVER['DOCUMENT_ROOT'].'/entities/Role.php';
?>
<!DOCTYPE html>
<HTML>
<HEAD>
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
<TITLE>Система менеджмента качества УО «ВГУ им. П. М. Машерова»</TITLE>
<LINK rel="stylesheet" type="text/css" href="/view/css/main.css">
</HEAD>
<BODY>
<?php
if(isset($_SESSION['user'])) {
	$user = unserialize($_SESSION['user']);
	$roles = $user->getRoles();
?>
	<SCRIPT type="text/javascript" src="/view/javascripts/date.js"></SCRIPT>
	<DIV id="header">
		<DIV id="user">
			<P>
				<STRONG>текущий пользователь</STRONG>:
				<EM><a href="/person/editPrivate.html" ><?php echo $user->getFullName();?></a></EM>
			</P>
			<P>
				<STRONG>права доступа</STRONG>:
				<EM>
<?php
	$roles = $user->getRoles();
	$roleNames = array();
	foreach($roles as $role) {
		$roleNames[] = $role->getName();
	}
	echo join(', ', $roleNames);
?>
				</EM>
			</P>
			<DIV class="clear"></DIV>
		</DIV>
		<DIV id="date">
			<P><A href="/logout.html">Выход</A></P>
			<P>
				<STRONG>сегодня</STRONG>:
				<EM id="date-value"><?php echo date('d.m.Y', time());?></EM>
			</P>
		</DIV>
		<DIV class="clear"></DIV>
	</DIV>
	<SCRIPT type="text/javascript">
		var date = document.getElementById("date-value");
		date.innerHTML = formatDate(date.innerHTML);
	</SCRIPT>
<?php
}
if(isset($_SESSION['menu'])) {
	$menu = unserialize($_SESSION['menu']);
?>
	<UL id="menu">
<?php
	foreach($menu as $path => $item) {
		if($_SERVER['REQUEST_URI'] === $path) {
?>
		<LI id="current"><?php echo $item;?></LI>
<?php
		} else {
?>
		<LI><A href="<?php echo $path;?>"><?php echo $item;?></A></LI>
<?php
		}
	}
?>
	</UL>
<?php
}
?>